package org.example.controller.common.permission;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.example.model.user.dtos.UserIdentityDto;
import org.example.utils.UserIdThreadLocalUtils;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class PermissionAspect {

    /**
     * 检查当前用户权限是否合法
     */
    @Around("@annotation(org.example.controller.common.permission.PermissionControl)")
    public Object  checkPermissionControl (ProceedingJoinPoint joinPoint) throws Throwable{
        log.info("##########【环绕通知中的前置通知】##########");
        UserIdentityDto userIdentityDto = UserIdThreadLocalUtils.getUser();
        Object returnVale = joinPoint.proceed();
        log.info("##########【环绕通知中的后置通知】##########");
        return returnVale;
    }

}
